package com.tjbank.cssys.mybatis.impl;

import com.tjbank.cssys.mybatis.IamGroupDao;
import com.tjbank.cssys.mybatis.entity.IamGroup;
import com.tjbank.cssys.mybatis.entity.IamGroupKey;
import com.tjbank.cssys.mybatis.mapper.IamGroupMapper;
import com.tjbank.cssys.mybatis.sqlbuilder.IamGroupSqlBuilder;
import java.util.List;
import javax.annotation.Resource;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * IamGroupDaoImpl
 * 
 * @author PG(Auto Generator)
 * @version V2.0
 */
@Service
public class IamGroupDaoImpl implements IamGroupDao {
    @Resource
    private IamGroupMapper iamGroupMapper;

    public IamGroupDaoImpl() {
        super();
    }

    @Override
    public List<IamGroup> selectListBySqlBuilderWithBLOBs(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        return iamGroupMapper.selectBySqlBuilderWithBLOBs(iamGroupSqlBuilder);
    }

    @Override
    public List<IamGroup> selectListBySqlBuilder(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        return iamGroupMapper.selectBySqlBuilder(iamGroupSqlBuilder);
    }

    @Override
    public IamGroup selectBySqlBuilderWithBLOBs(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        List<IamGroup> listIamGroups = selectListBySqlBuilderWithBLOBs(iamGroupSqlBuilder);
        if (listIamGroups == null || listIamGroups.isEmpty()) {
            return null;
        } else if (listIamGroups.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamGroups.get(0);
    }

    @Override
    public IamGroup selectBySqlBuilder(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        List<IamGroup> listIamGroups = selectListBySqlBuilder(iamGroupSqlBuilder);
        if (listIamGroups == null || listIamGroups.isEmpty()) {
            return null;
        } else if (listIamGroups.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamGroups.get(0);
    }

    @Override
    public IamGroup selectByPrimaryKey(IamGroupKey iamGroupKey) throws RuntimeException {
        return iamGroupMapper.selectByPrimaryKey(iamGroupKey);
    }

    @Override
    public long countBySqlBuilder(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        return iamGroupMapper.countBySqlBuilder(iamGroupSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insert(IamGroup iamGroup) throws RuntimeException {
        return iamGroupMapper.insert(iamGroup);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insertUseBatch(List<IamGroup> listIamGroups) throws RuntimeException {
        return iamGroupMapper.insertUseBatch(listIamGroups);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilder(IamGroup iamGroup, IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        iamGroupSqlBuilder.setUpdateObject(iamGroup);
        return iamGroupMapper.updateBySqlBuilder(iamGroupSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilderSelective(IamGroup iamGroup, IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        iamGroupSqlBuilder.setUpdateObject(iamGroup);
        return iamGroupMapper.updateBySqlBuilderSelective(iamGroupSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKey(IamGroup iamGroup) throws RuntimeException {
        return iamGroupMapper.updateByPrimaryKey(iamGroup);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKeySelective(IamGroup iamGroup) throws RuntimeException {
        return iamGroupMapper.updateByPrimaryKeySelective(iamGroup);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteBySqlBuilder(IamGroupSqlBuilder iamGroupSqlBuilder) throws RuntimeException {
        return iamGroupMapper.deleteBySqlBuilder(iamGroupSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteByPrimaryKey(IamGroupKey iamGroupKey) throws RuntimeException {
        return iamGroupMapper.deleteByPrimaryKey(iamGroupKey);
    }
}